// 嵌入 App 的 HTML5 页面，如果和 App 有交互，需要加载此文件
var bt_show_bottom_bar;  // 'YES' or 'NO'
var cnl_webview; // iOS WebView close button '1' or '0' 
var shr_flag; // iOS WebView share button '1' or '0'
var bookmark_flag; // 是否显示WebView 收藏按钮 '1' or '0'
var disable_back; //点击后退是否直接关闭webview '1' :是 '0':否
var download_flag; // 是否现实下载按钮 '1' :是 '0':否
var shr_url; // 微信分享 url
var breadtrip_banner_title;
var _breadtrip_header_list;
var _breadtrip_on_page_leave;  // {'zh': '您确定要退出购买流程，返回首页吗？',
                               //  'en': 'Are you sure to cancel the purchasing?'}

var btAppSchema = {
    // versionCompare: function (a,b){var c,d,e,f=/(\.0)+[^\.]*$/;for(a=(a+"").replace(f,"").split("."),b=(b+"").replace(f,"").split("."),e=Math.min(a.length,b.length),c=0;e>c;c++)if(d=parseInt(a[c],10)-parseInt(b[c],10),0!==d)return d;return a.length-b.length;},
    // gteVersion: function (a,b){return this.versionCompare(a,b)>=0;}, // a 大于等于 b
    // ltVersion: function (a,b){return this.versionCompare(a,b)<0;}, // a 小于 b
    w: $('body').width(),
    h: $(window).height(),
    user_agent: parseInt($('body').attr('data-user-agent'), 10),
    // 0.default 1.iPhone 2.iPad 3.iPod 4.Android
    appVersion: $('body').attr('data-version').replace('&#39;','').replace(/[\[\]']+/g,'').split("_", 2)[1],
    popupDownload: '<div id="popup-download-mask" style="display: none; width: 100%; height: 100%; position: fixed; top: 0; left: 0; background: rgba(0, 0, 0, 0.4); z-index: 999;"></div>' +
            '<div id="popup-download" style="display: none; background:#FBF7ED; position: fixed; z-index: 1000; left: 15px; padding-top: 19px; top: 0; text-align: left;">' +
            '<p id="popup-download-title" style="color: #50BDCB; font-size: 18px; border-bottom: 1px solid #50BDCB; padding-bottom: 7px; line-height: 1.2; margin: 0 15px;">升级提醒</p>'+
            '<p id="popup-download-content" style="color: #5c5c5c; font-size: 18px; line-height: 1; margin: 20px 15px;">您的面包旅行App版本较低，无法观看视频。请升级后，观看视频，并获得更好的使用体验。</p>' +
            '<p style="background: #49BDCC; border-bottom: 3px solid #2D9DAA; padding: 8px 0; text-align: center;">' +
                '<a id="popup-download-cancel" href="###" style="display: inline-block; height: 24px; line-height: 24px; color: #FFF; text-decoration: none; font-size: 18px; width: 49%; border-right: 1px solid #2D9DAA;">知道了</a>' +
                '<a id="popup-download-ok" href="http://breadtrip.com/download/" style="display: inline-block; height: 24px; line-height: 24px; color: #FFF; text-decoration: none; font-size: 18px; width: 49%;">立即下载</a>' +
            '</p>' +
            '</div>',
    clubActivityListJson: "",
    currentBookmarkBtnState: 0,
    changeFriendshipCallback: function ( statusCode, friendship ) {
        if (statusCode === 0) {
            alert('有错误发生，请稍后再试。');
        } else {
            //0.已屏蔽该人 1.正常 2.关注中 4.好友 5.已被该人屏蔽
            var obj = $('#friendship');
            switch (friendship) {
                case 1:
                    obj.attr('href', obj.data('followuser'));
                    obj.find('b').text('加关注');
                    obj.show();
                    break;
                case 2:
                    obj.attr('href', obj.data('jumptouser'));
                    obj.find('b').text('已关注');
                    obj.addClass('following');
                    obj.show();
                    break;
                case 4:
                    obj.attr('href', obj.data('jumptouser'));
                    obj.find('b').text('好友');
                    obj.addClass('follow-friend');
                    obj.show();
                    break;
                default:
                    obj.hide();
                    break;
            }
        }
    },
    followUser: function( userId ) {
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法关注，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法关注，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法关注，请下载更新后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = 'app:follow:' + userId;
                } else if ( this.user_agent === 4 ) {
                    android.addFollowings(userId);
                }
            }
        } else {
            window.location.href = "/u/" + userId;
        }
    },
    jumpToUser: function( userId, userName)  {
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法打开用户的个人主页，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法打开用户的个人主页，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法打开用户的个人主页，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = 'app:jump:user:' + userId;
                } else if ( this.user_agent === 4 ) {
                    android.startUserInfoActivity(parseInt(userId, 10), userName.toString());
                }
            }
        } else {
            window.location.href = "/u/" + userId;
        }
    },
    jumpToCurrentUserInfo: function(){
        if ( this.appVersion ) {
            if ( this.user_agent === 1  && this.appVersion > '5.0.0' ) {
                window.location.href = 'app:jump:accountsettings';
            }else if ( this.user_agent === 4 && this.appVersion >= '5.0.0' ) {
                android.startCurrentPersonInfo();
            }else if( this.user_agent == 2){
                
            }else{
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法打开个人信息页，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法通过第三方登录，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
            }
        } else {
            
        }
    },
    jumpToTrip: function(tripId) {
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看游记，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = 'app:jump:trip:' + tripId;
                } else if ( this.user_agent === 4 ) {
                    android.startBrowseTripActivity(parseInt(tripId, 10));
                }
            }
        } else {
            window.location.href = "/trips/" + tripId;
        }
    },
    jumpToTripComment: function(tripId,commentId) {
        if ( this.appVersion ) {
            if( this.user_agent === 2 ){
                if ( this.appVersion < '3.2.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看游记评论，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看游记评论，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else {
                    window.location.href = 'app:jump:trip:' + tripId + ':comment';
                }
            }else if( this.user_agent === 1 ){
                if( this.appVersion >= '4.3.0' ){
                    window.location.href = 'app:jump:trip:' + tripId + ':comment' + (commentId ? (":"+commentId ):"");
                }else{
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看游记评论，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看游记评论，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                }
            }else if( this.user_agent === 4 ){
                if( this.appVersion >= '4.2.1' ){
                    if( this.appVersion >= '4.3.1'){
                        android.startTripCommentsActivity(parseInt(tripId, 10),parseInt(commentId, 10));
                    }else{
                        android.startTripCommentsActivity(parseInt(tripId, 10));
                    }
                    
                }else{
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看游记评论，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看游记评论，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                }
            }
        } else {
            window.location.href = "/trips/" + tripId;
        }
    },
    jumpToWaypoint: function(tripId, waypointId) {
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看游记图片，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看游记图片，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看游记图片，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = 'app:jump:trip:' + tripId + ':waypoint:' + waypointId;
                } else if ( this.user_agent === 4 ) {
                    android.startBrowseTripActivity(parseInt(tripId, 10), parseInt(waypointId, 10));
                }
            }
        } else {
            window.location.href = "/trips/" + tripId + "/#wp" + waypointId;
        }
    },
    jumpToWaypointAnomynous: function(tripId, waypointId) {
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看游记图片，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看游记图片，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看游记图片，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                } else if ( this.user_agent === 4 ) {
                    android.startLoginAndBrowseTrip(parseInt(tripId, 10), parseInt(waypointId, 10));
                }
            }
        } else {
            window.location.href = "/trips/" + tripId + "/#wp" + waypointId;
        }
    },
    commentWaypoint: function(tripId, waypointId, commentId) {
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法评论照片，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法评论照片，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法评论照片，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:jump:trip:" + tripId + ":waypoint:" + waypointId + ':comment';
                } else if ( this.user_agent === 4 ) {
                    if(this.appVersion >= '4.3.1'){
                        android.startCommentActivity(parseInt(tripId, 10), parseInt(waypointId, 10),parseInt(commentId, 10));
                    }else{
                        android.startCommentActivity(parseInt(tripId, 10), parseInt(waypointId, 10));
                    }
                    
                }
            }
        } else {
            window.location.href = "/trips/" + tripId + "/?extend_comment=" + waypointId + "#wp" + waypointId;
        }
    },
    jumpToDestination: function(destName, destId, destType) {
        /* 方法已弃用 */
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:jump:place:destination/place/" + destType + "/" + destId;
                } else if ( this.user_agent === 4 ) {
                    android.startSpotActivitiy(destName, destId, destType);
                }
            }
        } else {
            window.location.href = "/tinysites/sites/" + destType + "/" + destId;
        }
    },
    jumpToDestinationTab: function(destName, destId, destType, tabTag, tipId, tipCount) {
        /*
        var TAG_OVERVIEW = "overview";
        var TAG_PHOTOS = "photos";
        var TAG_TRIPS = "trips";
        var TAG_TIPS = "tips";
        var TAG_FEED = "feed";
        iOS 3.5.0 / Android 3.4.0 新增 map, places
        iOS 3.6.0 / Android 3.5.0 新增 experience 和  offlinemap
        */
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    if ( this.appVersion < '3.3.0' || ((tabTag == 'map' || tabTag == 'places') && this.appVersion < '3.5.0') || ((tabTag == 'experience' || tabTag == 'offlinemap') && this.appVersion < '3.6.0') ) {
                        this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                        // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '暂时忽略');
                    }else{
                        if ( tipId && this.appVersion >= '4.0.0' ) {
                            window.location.href = "app:jump:place:destination/place/" + destType + "/" + destId + ":" + tabTag + ":" + tipId;
                        } else{
                            window.location.href = "app:jump:place:destination/place/" + destType + "/" + destId + ":" + tabTag;
                        }
                    }
                } else if ( this.user_agent === 4 ) {
                    if ( ((tabTag == 'map' || tabTag == 'places') && this.appVersion < '3.4.0') || ((tabTag == 'experience' || tabTag == 'offlinemap') && this.appVersion < '3.5.0') ) {
                        this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                        // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '暂时忽略');
                    }else{
                        if ( tipId && this.appVersion >= '4.0.0' ) {
                            if(this.appVersion >= '4.3.1'){
                                android.startSpotActivity(destName, destId+"", destType, tabTag, tipId, tipCount);
                            }else{
                                android.startSpotActivity(destName, destId+"", destType, tabTag, tipId);
                            }
                            
                        } else{
                            android.startSpotActivity(destName, destId+"", destType, tabTag);
                        }
                    }
                }
            }
        } else {
            window.location.href = "/mobile/destination/" + destType + "/" + destId + "/";
        }
    },
    jumpToDestinationSubTab: function(destName, destId, destType, tabTag, subTabTag) {
        // 从 iOS 3.3.0 版起弃用
        /*
        var TAG_TRIP = 0;
        var TAG_PHOTO = 1;
        var TAG_LIVE = 2;
        */
        if ( this.appVersion ) {
            if ( this.appVersion < '2.3.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法查看目的地，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:jump:place:destination/place/" + destType + "/" + destId + ":" + tabTag + ":" + subTabTag;
                } else if ( this.user_agent === 4 ) {
                    android.startSpotActivity(destName, destId, destType, tabTag, subTabTag);
                }
            }
        } else {
            window.location.href = "/tinysites/sites/" + destType + "/" + destId;
        }
    },
    jumpToLogin: function(nexturl) {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.1.2' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:login";
                } else if ( this.user_agent === 4 ) {
                    android.startLoginActivity();
                }
            }
        } else {
            window.location.href = "/accounts/login/?next="+nexturl;
        }
    },
    jumpToSNSLogin: function(sns_type, nexturl) {
        /*
        sns_type
        wechat: 微信
        weibo: 新浪微博
        qq: 腾讯 QQ
        tencent: 腾讯微博
        */
        if ( this.appVersion ) {
            if ( (this.user_agent === 1 || this.user_agent === 2) && this.appVersion >= '4.4.0' ) {
                if ( sns_type == 'wechat' ) { sns_type = 'weixin' }
                window.location.href = "app:snslogin:" + sns_type;
            }else if ( this.user_agent === 4 && this.appVersion >= '4.4.1' ) {
                android.startSNSLoginActivity(sns_type);
            }else{
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法通过第三方登录，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法通过第三方登录，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
            }
        } else {
            if ( sns_type == 'weibo' ) {
                window.location.href = "/accounts/sina_2_login/?display=mobile";
            }else if ( sns_type == 'qq' ) {
                window.location.href = "/accounts/qq_login/";
            }else if ( sns_type == 'tencent' ) {
                window.location.href = "/accounts/tencent_login/";
            }else if ( sns_type == 'wechat' ) {
                alert('暂时无法使用微信账号直接登录，请使用面包旅行App直接登录');
            }
        }
    },
    jumpToAddTrip: function() {
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '3.1.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法创建游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法创建游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                    // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法创建游记，请更新App后再试试。', '暂时忽略');
                } else {
                    window.location.href = "app:edit:trip";
                }
            } else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '3.1.2' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法创建游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法创建游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                    // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法创建游记，请更新App后再试试。', '暂时忽略');
                } else {
                    android.startTripEditActivity();
                }
            }
        } else {
            window.location.href = "/accounts/login/?next=/";
        }
    },
    getJumpToShareProductViaWeixinParams: function () {
    },
    jumpToShareProductViaWeixin: function(title, content, image, url) {
        this.getJumpToShareProductViaWeixinParams = function() {
            rtn = {"title": title,
                   "content": content,
                   "image_url": image,
                   "product_url": url};
            return JSON.stringify(rtn);
        };
        if ( this.appVersion ) {
            if ( this.appVersion < '3.1.2' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法分享产品，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法分享产品，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法分享产品，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:share_product_via_weixin:btAppSchema.getJumpToShareProductViaWeixinParams()";
                } else if ( this.user_agent === 4 ) {
                    android.sendGiftToWeixinFriend(title, content, image, url);
                }
            }
        } else {
        }
    },
    jumpToShare: function () {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.1.4' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法分享，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法分享，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法分享产品，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:share";
                } else if ( this.user_agent === 4 ) {
                    android.startShareButton();
                }
            }
        } else {
        }
    },
    jumpToWeb: function(url) {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.2.0' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:web:" + url;
                } else if ( this.user_agent === 4 ) {
                }
            }
        } else {
            window.location.href = url;
        }
    },
    jumpToWebView: function (url) {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.4.1' ) {
                // this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '暂时忽略');
                window.location.href = url;
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    if ( this.appVersion < '3.5.1' ) {
                        // this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                        // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法跳转页面，请更新App后再试试。', '暂时忽略');
                        window.location.href = url;
                    }else{
                        window.location.href = "app:jump:webview:" + url;
                    }
                } else if ( this.user_agent === 4 ) {
                    android.startWebActivity(url);
                }
            }
        } else {
            window.location.href = url;
        }
    },
    getAjaxData: function (json) {
        /**
         * App 主动调用 btAppSchema.getAjaxData(json) 方法
         *
         * json = {
         *     "url": "http://breadtrip.com/mobile/hunter/products/",
         *     "method": "get",
         *     "data": {
         *         "city_name": "北京",
         *         "tab_list": [1, 2, 3],       // 过滤标签id
         *         "sorted_id": 1,              // 排序策略id
         *         "start": 1,                  // 分页查询，从第几条记录开始
         *         "lat": 39.90960456049752,
         *         "lng": 116.3972282409668
         *     }
         * }
         *
         * 参考文档：romoo/100million/wikis : city-hunter-product-list
         * 
         */
    },
    jumpToMessage: function (userId ,userName) {
        if ( this.appVersion ) {
            if( this.user_agent === 2 ){
                if ( this.appVersion < '3.2.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else {
                    window.location.href = "app:message:" + userId;
                }
            }else if( this.user_agent === 1 ){
                if( this.appVersion >= '4.3.0' ){
                    window.location.href = "app:message:" + userId + ":username:" + userName;
                }else{
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                }
            }else if( this.user_agent === 4 ){
                if( this.appVersion >= '4.2.0' ){
                    android.startPrivateMessageActivity(parseInt(userId,10), userName.toString());
                }else{
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                }
            }
        } else {
            window.location.href = '/messages/talk/' + userId + '/';
        }
    },
    jumpToWxpay: function (oid) {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.2.1' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:transaction:wxpay:" + oid;
                } else if ( this.user_agent === 4 ) {
                    android.wxPay(oid);
                }
            }
        } else {
        }
    },
    jumpToAlipay: function (subject, body, price, oid) {
    /**
     * 跳转支付宝支付
     *
     * @param {string} subject 商品名称
     * @param {string} body    商品详情
     * @param {string} price   价格
     * @param {string} oid     订单ID
     **/
        var url = window.location.origin + '/tp/order/pay/alipay/' + oid + '/';

        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {

                if ( this.appVersion < '6.1.0' ) {
                    window.location.href = url;
                } else {
                    window.location.href = url;
                }

            } else if ( this.user_agent === 4 ) {

                if ( this.appVersion < '6.1.0' ) {
                    window.location.href = url;
                } else {
                    this.getPaymentId(oid, function (pid) {
                        var host = window.location.host;
                        // 支付宝回调域名

                        android.aliPay(subject, body, price, pid, host);
                    })
                }

            }
        } else {
            window.location.href = url;
        }
    },
    jumpToMap: function (title, latitude, longitude, mapZoom) {
        var url = window.location.origin + '/mobile/map/?' + 'title=' + title + '&latitude=' + latitude + '&longitude=' + longitude + '&zoom=' + mapZoom;
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.0' ) {
                    this.jumpToWebView(url);
                } else{
                    window.location.href = 'app:jump:map:' + title + ':' + latitude + ':' + longitude + ':' + mapZoom;
                }
            } else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '5.2.0' ) {
                    this.jumpToWebView(url);
                } else{
                    android.startMapActivity(title, parseFloat(latitude), parseFloat(longitude), parseFloat(mapZoom));
                }
            }
        } else {
            this.jumpToWebView(url);
        }
    },
    jumpToNewTrip : function(tripId){
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.2' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = 'app:jump:newtrip:' + tripId;
                }
            }else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '6.0.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    android.startSpotDispalyFragmentActivity(parseInt(tripId));
                }
            }
        } else {
            window.location.href = "/btrip/trip/" + tripId;
        }
    },
    jumpToNewTripWithSpot : function(tripId,spotId){
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.2' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = 'app:jump:newtrip:' + tripId + ':spot:' + spotId;
                }
            }else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '6.0.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事游记，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    android.startSpotDispalyLargerFragment(parseInt(tripId),parseInt(spotId));
                }
            }
        } else {
            window.location.href = "/btrip/trip/" + tripId;
        }
    },
    jumpToSpot : function(spotId){
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.2' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = 'app:jump:spot:' + spotId;
                }
            }else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '6.0.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    android.startSpotDetailActivity(parseInt(spotId));
                }
            }
        } else {
            window.location.href = "/btrip/spot/" + spotId;
        }
    },
    jumpToSpotComment : function(spotId,commentId){
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.2' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = 'app:jump:spot:' + spotId + ':comment:' + commentId;
                }
            }else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '6.0.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法查看故事，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    android.showSpotDetailComment(parseInt(spotId),parseInt(commentId));
                }
            }
        } else {
            window.location.href = "/btrip/spot/" + spotId + '#comment';
        }
    },
    jumpToAddSpot : function(type, targetId){
        /**
         * 跳转新增生活故事界面
         *
         * @param {number} type 关联类型type，可为空。目前只有 cityhunter产品，取值为1
         * @param {targetId} type 关联类型id，可为空。目前只有 cityhunter产品，取值产品id
         **/
         if ( this.appVersion ) {
            if ( this.appVersion < '6.1.0' ) {
                this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法创建生活故事，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法创建生活故事，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    if(type && targetId){
                        window.location.href = "app:edit:spot:" + type + ":" + targetId;
                    }else{
                        window.location.href = "app:edit:spot";
                    }
                } else if ( this.user_agent === 4 ) {
                    android.startLifeStoryEditActivity( parseInt(type) || '', parseInt(targetId) || '');

                }
            }
        } else {
        }

    },
    getPaymentId: function (oid, callback) {
    /**
     * 通过 orderId 得到 paymentId
     *
     * @param {string}   oid      订单ID
     * @param {function} callback 方法回调
     **/
        var url = '/payment/alipay/native/' + oid + '/';
        $.ajax({
            url: url,
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                callback && callback(data.trans + '');
            }
        });
    },
    jumpToOrder: function (orderId) {
        /**
         * 跳转订单管理页面
         *
         * @param {number} orderId 订单 ID
         **/
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.1' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = "app:jump:order:" + orderId;
                }
            } else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '5.3.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else {
                    android.showOrder(parseFloat(orderId));
                }
            }
        } else {
        }
    },
    jumpToCancelOrder: function (orderId) {
        /**
         * 跳转订单取消页面
         *
         * @param {number} orderId 订单 ID
         **/
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.0.2' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法取消订单，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = "app:jump:cancelorder:" + orderId;
                }
            } else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '6.1.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法取消订单，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else {
                    android.showCancelOrder(parseFloat(orderId));
                }
            }
        } else {
        }
    },
    jumpToOrderComment: function (orderId, productId, type, userId) {
        /**
         * 跳转订单评价页面
         *
         * @param {number} orderId   产品ID
         * @param {number} productId 产品ID
         * @param {number} type      评价类型：1 评价猎人、2 评价客人
         *
         * 
         **/
        if (!userId) {
            userId = 0;
        }
        if ( this.appVersion ) {
            if ( this.user_agent === 1 || this.user_agent === 2 ) {
                if ( this.appVersion < '6.1.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法取消订单，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单评价页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else{
                    window.location.href = "app:jump:ordercomment:" + orderId + ':product:' + productId + ':type:' + type;
                }
            } else if ( this.user_agent === 4 ) {
                if ( this.appVersion < '6.1.0' ) {
                    this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法取消订单，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转订单评价页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                } else {
                    android.showOrderComment(parseFloat(orderId), parseFloat(productId), parseFloat(type));
                }
            }
        } else {
        }
    },
    refreshUser: function (uid,followingcount) {
        if ( this.appVersion ) {
            if((this.user_agent == 2 && this.appVersion >= '3.2.0') || (this.user_agent == 1 && this.appVersion >= '4.3.0')){
                window.location.href = "app:refresh:user:" + uid + ":following:" + followingcount;
            }else if(this.user_agent === 4){
                
            }
        } else {
        }
    },
    resetHeight: function (windowheight) {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.3.0' ) {
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:ready:resetheight:" + windowheight;
                } else if ( this.user_agent === 4 ) {
                }
            }
        } else {
        }
    },
    showNotification: function (message) {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.4.0' ) {
                // this.showUpdatePopup('升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', '升级提醒', '您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '立即下载', '暂时忽略', 'http://breadtrip.com/download/');
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法跳转私信页面，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:notification:" + message;
                } else if ( this.user_agent === 4 ) {
                    android.showToast(message);
                }
            }
        } else {
        }
    },
    showFormattedNotification: function (message) {
        if ( this.appVersion ) {
            if (
                (this.user_agent === 1 || this.user_agent === 2) &&
                this.appVersion >= '4.3.0'
            ) {
                window.location.href = "app:formatted_notification:" + message;
                
            }else if (
                this.user_agent === 4 &&
                this.appVersion >= '4.2.1'
            ) {
                android.showFormattedToast(message);
            }
        } else {
        }
    },
    showConfirmWindow: function (cntitle, cnmessage, cnconfirm, cncancel, entitle, enmessage, enconfirm, encancel, callback_url, callback_method) {
        // callback_method
        /*
        callback_method(success){} App 返回 success 结果，true or false
        */
        if ( this.appVersion ) {
            console.log(callback_method);
            if ( !callback_method ) { callback_method = ''; }
            console.log(callback_method);
            if ( this.user_agent === 1 ) {
                var _json = {
                    "zhcn":{
                        "title": cntitle,
                        "message": cnmessage,
                        "confirm": cnconfirm,
                        "cancel": cncancel,
                        "callback_url": callback_url,
                        "callback_method": callback_method
                    },"en":{
                        "title": entitle,
                        "message": enmessage,
                        "confirm": enconfirm,
                        "cancel": encancel,
                        "callback_url": callback_url,
                        "callback_method": callback_method
                    }};
                var _jsonToStr = encodeURIComponent(JSON.stringify(_json));
                console.log(_jsonToStr);
                window.location.href = "app:alert:" + _jsonToStr;
            }else if ( this.user_agent === 4 ) {
                if ( callback_method !== '' ) { callback_method = 'javascript:' + callback_method + '(%s)'; }
                android.showDialog(cntitle, cnmessage, cncancel, cnconfirm, callback_url, callback_method);
            }
        }
    },
    hideWebViewLoading: function () {
        if ( this.appVersion ) {
            if ( (this.user_agent === 1 || this.user_agent === 2) && this.appVersion >= '3.6.0' ) {
                window.location.href = "app:load:finish";
            }else if ( this.user_agent === 4 && this.appVersion >= '3.5.0' ) {
                android.setProgressDialog(false);
            }
        }
    },
    hideUpdatePopup: function() {
        $('#popup-download').hide();
        $('#popup-download-mask').hide();
    },
    // showUpdatePopup: function(text, cancel_text, ok_text) {
    showUpdatePopup: function(cntitle, cnmessage, cnconfirm, cncancel, entitle, enmessage, enconfirm, encancel, callback_url, callback_method) {
        if ( this.appVersion >= '3.5.0' ) {
            if (!cncancel) { cncancel = '取消'; }
            if (!cnconfirm) { cnconfirm = '确定'; }
            if ( this.user_agent === 1 ) {
                this.showConfirmWindow(cntitle, cnmessage, cnconfirm, cncancel, cntitle, cnmessage, enconfirm, encancel, callback_url, callback_method);
            }else if( this.user_agent === 4 ){
                android.showDialog(cntitle, cnmessage, cncancel, cnconfirm, callback_url, callback_method);
            }
        }else{
            if (cncancel) {
                $('#popup-download-cancel').text(cncancel);
            }
            if (cnconfirm) {
                $('#popup-download-ok').text(cnconfirm);
            }
            if (cnmessage) {
                $('#popup-download-content').text(cnmessage);
            }
            $('#popup-download').css({
                width: btAppSchema.w - 30,
                top: (btAppSchema.h - 287)/2
            }).show();
            $('#popup-download-mask').show();
        }
    },
    setClubActivityList: function(json) {
        this.clubActivityListJson = json;
        if ( this.appVersion ) {
            if ( this.appVersion < '3.1.2' ) {
                this.showUpdatePopup('您未安装最新版本的面包旅行App，无法打开用户的个人主页，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    // IOS 的会主动调用 btAppSchema.getClubActivityList();
                } else if ( this.user_agent === 4 ) {
                    android.setClubActivityList(json);
                }
            }
        } else {
        }
    },
    getClubActivityList: function() {
        return this.clubActivityListJson;
    },
    closeWebView: function () {
        if ( this.appVersion ) {
            if( (this.user_agent == 1  || this.user_agent == 2 ) && this.appVersion > '4.5.0'){
                window.location.href = "app:closeview";
            }
        } 
    },
    toggleBookmark: function() {
        // 收藏/取消收藏 网页
    },
    changeBookmarkBtnState: function(state) {
        // 修改APP右上角收藏按钮状态
        this.currentBookmarkBtnState = parseInt(state);
        if ( this.appVersion ) {
            if ( this.appVersion < '4.1.0' ) {
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法...，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                    window.location.href = "app:bookmark:state:" + state;
                } else if ( this.user_agent === 4 ) {
                    android.setBookmarkState(state);
                }
            }
        } else {
        }
    },
    onPageLoad: function() {
        if ( this.appVersion ) {
            if ( this.appVersion < '3.1.1' ) {
                // this.showUpdatePopup('您未安装最新版本的面包旅行App，无法打开用户的个人主页，请更新App后再试试。', '暂时忽略');
            } else {
                if ( this.user_agent === 1 || this.user_agent === 2 ) {
                } else if ( this.user_agent === 4 ) {
                    if(typeof(android) == "undefined") {
                    } else {
                        if ( this.appVersion >= '3.3.1' && ( cnl_webview == 1 ) ) {
                            android.showHomeButton(true);
                        }
                        if ( this.appVersion > '3.7.1' && ( disable_back == 1 ) ) {
                            android.setDisableBack(true);
                        }
                        if ( this.appVersion >= '4.2.0' && ( bookmark_flag == 1 ) ) {
                            android.showLikedButton(true);
                        }
                        if ( this.appVersion >= '4.2.0' && ( bookmark_flag == 0 ) ) {
                            android.showLikedButton(false);
                        }
                        if ( this.appVersion >= '4.4.1' && ( download_flag == 1 ) ) {
                            android.loadDownLoadButton(download_detail);
                        }
                        if(breadtrip_banner_title){
                            android.setTitle(breadtrip_banner_title);
                        }
                        
                        android.setTitleListView(_breadtrip_header_list);
                        if(shr_flag == 1) {
                            if ( this.appVersion >= '3.6.0' && shr_url ) {
                                android.loadShareButton(shr_text,
                                    shr_photo,
                                    shr_title,
                                    shr_summary,
                                    shr_image,
                                    shr_wechat_title_friend,
                                    shr_wechat_summary_friend,
                                    shr_wechat_title_circle,
                                    shr_wechat_summary_circle,
                                    shr_wechat_image,
                                    shr_url);
                            }else{
                                android.loadShareButton(shr_text,
                                    shr_photo,
                                    shr_title,
                                    shr_summary,
                                    shr_image,
                                    shr_wechat_title_friend,
                                    shr_wechat_summary_friend,
                                    shr_wechat_title_circle,
                                    shr_wechat_summary_circle,
                                    shr_wechat_image);
                            }
                        }
                        if(_breadtrip_on_page_leave) {
                            android.onBackPressed(
                                true, _breadtrip_on_page_leave['zh']
                            );
                        }
                    }
                }
            }
        } else {
        }
    },
    paymentRequestCallback: function (payment_name, success) {
        /*
        支付跳转 callback
        payment_name : 支付渠道名称 'wxpay', 'alipay'
        success : Boolean
        */
    },
    paymentResponseCallback: function (payment_name, success) {
        /*
        支付结果 callback
        payment_name : 支付渠道名称 'wxpay', 'alipay'
        success : Boolean
        */
    },
    WeixinShareCallback : function ( channel, success ) {
    },
    breadtrip_back: function(lang) {
        return _breadtrip_on_page_leave[lang];
    }
};

function breadtrip_back(lang) {
    if(_breadtrip_on_page_leave) {
        return btAppSchema.breadtrip_back(lang);
    }
}

function shareResultCallback( channel, success ) {
    // 微信分享回调 
    // channel 0 表示朋友圈，1 表示给好友    success表示是否成功
    btAppSchema.WeixinShareCallback(channel, success);
}

function onPageLoad() {
    btAppSchema.onPageLoad();
}

$(document).ready(function() {
    $(btAppSchema.popupDownload).appendTo('body');
    $('body').on('click', '#popup-download-mask, #popup-download-cancel', function() {
        btAppSchema.hideUpdatePopup();
    });
});
